Ext.namespace('Divo');
Ext.namespace('Divo.app');

Divo.app.HighValueMaterialDetailForm = Ext.extend(Divo.Base.EditForm, {
      fields : new Ext.util.MixedCollection(),
      dataRecordMeta : Ext.data.Record.create([{
            name : "_p_record_status",
            type : "string"
          }, {
            name : "id",
            type : "float"
          }, {
            name : "name",
            type : "string"
          }, {
            name : "sId",
            type : "string"
          }, {
            name : "type",
            type : "string"
          }, {
            name : "materialName",
            type : "string"
          }, {
            name : "spec",
            type : "string"
          }, {
            name : "unit",
            type : "string"
          }, {
            name : "price",
            type : "float"
          }, {
            name : "consum",
            type : "string"
          }, {
            name : "code",
            type : "string"
          }]),
      initComponent : function() {
        var me = this;
        var tn = 1;

        this.fields.add("_p_record_status", new Ext.form.Hidden({
                  name : "_p_record_status"
                }));
        this.fields.add("id", new Ext.form.Hidden({
                  name : "id",
                  dataIndex : "id",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("sId", new Ext.form.Hidden({
                  name : "sId",
                  dataIndex : "sId",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("type", new Ext.form.Hidden({
                  name : "type",
                  dataIndex : "type",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("name", new app.base.TextField({
                  name : "name",
                  dataIndex : "name",
                  fieldLabel : "品牌名",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("materialName", new app.base.TextField({
                  name : "materialName",
                  dataIndex : "materialName",
                  fieldLabel : "厂家耗材名",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("spec", new app.base.TextField({
                  name : "spec",
                  dataIndex : "spec",
                  fieldLabel : "规格",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("unit", new app.base.TextField({
                  name : "unit",
                  dataIndex : "unit",
                  fieldLabel : "单位",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("price", new app.base.NumberField({
                  name : "price",
                  dataIndex : "price",
                  fieldLabel : "参考进价",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("consum", new app.base.TextField({
                  name : "consum",
                  dataIndex : "consum",
                  fieldLabel : "对应消耗品",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("code", new app.base.TextField({
                  name : "code",
                  dataIndex : "code",
                  fieldLabel : "耗材编码",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("typeG", new app.base.ComboBox({
                  id : 'combo-typeG',
                  name : "typeG",
                  dataIndex : "typeG",
                  fieldLabel : '选择类型',
                  store : Divo.com.Lib.getHighValueType(),
                  displayField : 'name',
                  valueField : 'id',
                  forceSelection : true,
                  mode : 'remote',
                  triggerAction : 'all',
                  editable : false,
                  allowBlank : false,
                  labelSeparator : ":*",
                  selectOnFocus : true,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true,
                  onSelect : function(record) {
                    var data = record.data;
                    this.setValue(data.name);
                    me.setFieldValue("type", data.name);
                    this.onTriggerClick();
                  }
                }));
        Ext.apply(this, {
              items : [this.fields.get("_p_record_status"), {
                layout : "form",
                columnWidth : 1,
                labelAlign : "right",
                labelWidth : 100,
                items : [this.fields.get("id"), this.fields.get("sId"),
                    this.fields.get("type"), this.fields.get("typeG"),
                    this.fields.get("name"), this.fields.get("materialName"),
                    this.fields.get("spec"), this.fields.get("unit"),
                    this.fields.get("price"), this.fields.get("consum"),
                    this.fields.get("code")]
              }],
              border : false,
              frame : true,
              firstFocusFieldName : "name"
            });

        Divo.app.HighValueMaterialDetailForm.superclass.initComponent.apply(
            this, arguments);
      }

      ,
      onRender : function() {
        Divo.app.HighValueMaterialDetailForm.superclass.onRender.apply(this,
            arguments);
      },
      newDataRecord : function() {
        return new this.dataRecordMeta({
              _p_record_status : "insert",
              id : "",
              name : "",
              sId : "",
              state : ""
            });
      }

    });
Ext.reg("Divo.app.HighValueMaterialDetailForm",
    Divo.app.HighValueMaterialDetailForm);